import { createStore } from 'redux'

export default function configureStore(rootReducer, initialState) {
	const store = createStore(rootReducer, initialState)

	if(module.hot) {
		// Enable Webpack hot module replacement for reducers
		module.hot.accept('../reducers', () => {
			const nextReducer = require('../reducers').default
			store.replaceReducer(nextReducer)
		})
	}

	return store
}